{\rtf1\ansi\ansicpg936\cocoartf1504\cocoasubrtf830
{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;\f1\fnil\fcharset134 PingFangSC-Regular;\f2\fswiss\fcharset0 Helvetica;
}
{\colortbl;\red255\green255\blue255;\red228\green124\blue72;\red0\green0\blue0;\red65\green204\blue69;
\red255\green255\blue255;\red0\green160\blue255;\red255\green44\blue56;\red198\green0\blue131;\red100\green80\blue255;
}
{\*\expandedcolortbl;;\csgenericrgb\c89600\c48800\c28400;\csgenericrgb\c0\c0\c0;\csgenericrgb\c25500\c80100\c27000;
\csgenericrgb\c100000\c100000\c100000;\csgenericrgb\c0\c62600\c100000;\csgenericrgb\c100000\c17100\c21900;\csgenericrgb\c77676\c0\c51293;\csgenericrgb\c39177\c31250\c99850;
}
\paperw11900\paperh16840\margl1440\margr1440\vieww18200\viewh11100\viewkind0
\deftab741
\pard\tx741\pardeftab741\pardirnatural\partightenfactor0

\f0\fs30 \cf2 \cb3 #pragma mark -  
\f1 \'ce\'a2\'d0\'c5\'d6\'a7\'b8\'b6\'b1\'be\'b5\'d8\'c7\'a9\'c3\'fb
\f2\fs24 \cf0 \

\f0\fs30 \cf4 //
\f1 \'b4\'b4\'bd\'a8\'b7\'a2\'c6\'f0\'d6\'a7\'b8\'b6\'ca\'b1\'b5\'c4
\f0 sign
\f1 \'c7\'a9\'c3\'fb
\f2\fs24 \cf0 \

\f0\fs30 \cf5 -(\cf6 NSString\cf5  *)createMD5SingForPayWithAppID:(\cf6 NSString\cf5  *)appid_key partnerid:(\cf6 NSString\cf5  *)partnerid_key prepayid:(\cf6 NSString\cf5  *)prepayid_key package:(\cf6 NSString\cf5  *)package_key noncestr:(\cf6 NSString\cf5  *)noncestr_key timestamp:(\cf6 UInt32\cf5 )timestamp_key\{
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf6 NSMutableDictionary\cf5  *signParams = [\cf6 NSMutableDictionary\cf5  \cf6 dictionary\cf5 ];
\f2\fs24 \cf0 \

\f0\fs30 \cf5     [signParams \cf6 setObject\cf5 :appid_key \cf6 forKey\cf5 :\cf7 @"appid"\cf5 ];\cf4 //
\f1 \'ce\'a2\'d0\'c5
\f0 appid 
\f1 \'c0\'fd\'c8\'e7
\f0 wxfb132134e5342
\f2\fs24 \cf0 \

\f0\fs30 \cf5     [signParams \cf6 setObject\cf5 :noncestr_key \cf6 forKey\cf5 :\cf7 @"noncestr"\cf5 ];\cf4 //
\f1 \'cb\'e6\'bb\'fa\'d7\'d6\'b7\'fb\'b4\'ae
\f2\fs24 \cf0 \

\f0\fs30 \cf5     [signParams \cf6 setObject\cf5 :package_key \cf6 forKey\cf5 :\cf7 @"package"\cf5 ];\cf4 //
\f1 \'c0\'a9\'d5\'b9\'d7\'d6\'b6\'ce
\f0   
\f1 \'b2\'ce\'ca\'fd\'ce\'aa
\f0  Sign=WXPay
\f2\fs24 \cf0 \

\f0\fs30 \cf5     [signParams \cf6 setObject\cf5 :partnerid_key \cf6 forKey\cf5 :\cf7 @"partnerid"\cf5 ];\cf4 //
\f1 \'c9\'cc\'bb\'a7\'d5\'cb\'ba\'c5
\f2\fs24 \cf0 \

\f0\fs30 \cf5     [signParams \cf6 setObject\cf5 :prepayid_key \cf6 forKey\cf5 :\cf7 @"prepayid"\cf5 ];\cf4 //
\f1 \'b4\'cb\'b4\'a6\'ce\'aa\'cd\'b3\'d2\'bb\'cf\'c2\'b5\'a5\'bd\'d3\'bf\'da\'b7\'b5\'bb\'d8\'b5\'c4\'d4\'a4\'d6\'a7\'b8\'b6\'b6\'a9\'b5\'a5\'ba\'c5
\f2\fs24 \cf0 \

\f0\fs30 \cf5     [signParams \cf6 setObject\cf5 :[\cf6 NSString\cf5  \cf6 stringWithFormat\cf5 :\cf7 @"%u"\cf5 ,timestamp_key] \cf6 forKey\cf5 :\cf7 @"timestamp"\cf5 ];\cf4 //
\f1 \'ca\'b1\'bc\'e4\'b4\'c1
\f2\fs24 \cf0 \

\f0\fs30 \cf5     
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf6 NSMutableString\cf5  *contentString  =[\cf6 NSMutableString\cf5  \cf6 string\cf5 ];
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf6 NSArray\cf5  *keys = [signParams \cf6 allKeys\cf5 ];
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf4 //
\f1 \'b0\'b4\'d7\'d6\'c4\'b8\'cb\'b3\'d0\'f2\'c5\'c5\'d0\'f2
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf6 NSArray\cf5  *sortedArray = [keys \cf6 sortedArrayUsingComparator\cf5 :^\cf6 NSComparisonResult\cf5 (\cf8 id\cf5  obj1, \cf8 id\cf5  obj2) \{
\f2\fs24 \cf0 \

\f0\fs30 \cf5         \cf8 return\cf5  [obj1 \cf6 compare\cf5 :obj2 \cf6 options\cf5 :\cf6 NSNumericSearch\cf5 ];
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \}];
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf4 //
\f1 \'c6\'b4\'bd\'d3\'d7\'d6\'b7\'fb\'b4\'ae
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf8 for\cf5  (\cf6 NSString\cf5  *categoryId \cf8 in\cf5  sortedArray) \{
\f2\fs24 \cf0 \

\f0\fs30 \cf5         \cf8 if\cf5  (   ![[signParams \cf6 objectForKey\cf5 :categoryId] \cf6 isEqualToString\cf5 :\cf7 @""\cf5 ]
\f2\fs24 \cf0 \

\f0\fs30 \cf5             && ![[signParams \cf6 objectForKey\cf5 :categoryId] \cf6 isEqualToString\cf5 :\cf7 @"sign"\cf5 ]
\f2\fs24 \cf0 \

\f0\fs30 \cf5             && ![[signParams \cf6 objectForKey\cf5 :categoryId] \cf6 isEqualToString\cf5 :\cf7 @"key"\cf5 ]
\f2\fs24 \cf0 \

\f0\fs30 \cf5             )
\f2\fs24 \cf0 \

\f0\fs30 \cf5         \{
\f2\fs24 \cf0 \

\f0\fs30 \cf5             [contentString \cf6 appendFormat\cf5 :\cf7 @"%@=%@&"\cf5 , categoryId, [signParams \cf6 objectForKey\cf5 :categoryId]];
\f2\fs24 \cf0 \

\f0\fs30 \cf5         \}
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \}
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf4 //
\f1 \'cc\'ed\'bc\'d3\'c9\'cc\'bb\'a7\'c3\'dc\'d4\'bf
\f0 key
\f1 \'d7\'d6\'b6\'ce
\f0   API 
\f1 \'c3\'dc\'d4\'bf
\f2\fs24 \cf0 \

\f0\fs30 \cf5     [contentString \cf6 appendFormat\cf5 :\cf7 @"key=%@"\cf5 , \cf7 @"
\f1 \'c9\'cc\'bb\'a7\'c3\'dc\'d4\'bf
\f0 "\cf5 ];
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf6 NSString\cf5  *result = [\ulth contentString\ulnone  \ulth md5String\ulnone ];\cf4 //md5
\f1 \'bc\'d3\'c3\'dc
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf8 return\cf5  result;
\f2\fs24 \cf0 \

\f0\fs30 \cf5 \}
\f2\fs24 \cf0 \
\

\f1\fs30 \cf5 \ulth \ulc5 \
\
\pard\tx741\pardeftab741\pardirnatural\partightenfactor0

\f0 \cf4 \cb3 \ulnone /**
\f2\fs24 \cf0 \

\f0\fs30 \cf4  *  MD5 
\f1 \'bc\'d3\'c3\'dc
\f2\fs24 \cf0 \

\f0\fs30 \cf4  *
\f2\fs24 \cf0 \

\f0\fs30 \cf4  *  @return 
\f1 \'bc\'d3\'c3\'dc\'ba\'f3\'d7\'d6\'b7\'fb\'b4\'ae
\f2\fs24 \cf0 \

\f0\fs30 \cf4  */
\f2\fs24 \cf0 \

\f0\fs30 \cf5 - (\cf6 NSString\cf5  *)md5String
\f2\fs24 \cf0 \

\f0\fs30 \cf5 \{
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf8 if\cf5 (\cf8 self\cf5  == \cf8 nil\cf5  || [\cf8 self\cf5  length] == \cf9 0\cf5 ) \cf8 return\cf5  \cf8 nil\cf5 ;
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf8 unsigned\cf5  \cf8 char\cf5  digest[CC_MD5_DIGEST_LENGTH], i;
\f2\fs24 \cf0 \

\f0\fs30 \cf5     CC_MD5([\cf8 self\cf5  UTF8String], (\cf8 int\cf5 )[\cf8 self\cf5  lengthOfBytesUsingEncoding:NSUTF8StringEncoding], digest);
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf6 NSMutableString\cf5  *ms = [\cf6 NSMutableString\cf5  \cf6 string\cf5 ];
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf8 for\cf5 (i=\cf9 0\cf5 ;i<CC_MD5_DIGEST_LENGTH;i++)
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \{
\f2\fs24 \cf0 \

\f0\fs30 \cf5         [ms appendFormat: \cf7 @"%02x"\cf5 , (\cf8 int\cf5 )(digest[i])];
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \}
\f2\fs24 \cf0 \

\f0\fs30 \cf5     \cf8 return\cf5  [ms \cf6 copy\cf5 ];
\f2\fs24 \cf0 \

\f0\fs30 \cf5 \}}